﻿using System.Text;

namespace TineMCE.NET.TinyMceCode
{
    public class CommonHelper
    {
        public static string GetTinyMceJS(string path, string control, int width, int height, bool enableXmlEncoding = false)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(string.Format("<script src=\"{0}tiny_mce/tiny_mce_src.js\" type=\"text/javascript\"></script>", path));
            sb.Append("<script type=\"text/javascript\">");
            sb.Append("tinyMCE.init({");
            sb.Append("mode : \"exact\",");
            if (enableXmlEncoding)
            {
                sb.Append("encoding : \"xml\",");
            }
            sb.Append(string.Format("elements: \"{0}\",", control));
            sb.Append("theme : \"advanced\",");
            sb.Append(string.Format("height: \"{0}\",", height.ToString()));
            sb.Append(string.Format("width: \"{0}\",", width.ToString()));
            sb.Append("plugins : \"advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,aspnetbrowser\",");
            sb.Append("theme_advanced_buttons1: \"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect\",");
            sb.Append("theme_advanced_buttons2: \"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code\",");
            sb.Append("theme_advanced_buttons3: \"aspnetbrowser,|,insertdate,inserttime,preview,|,forecolor,backcolor\",");
            sb.Append("theme_advanced_buttons4: \"\",");
            sb.Append("theme_advanced_toolbar_location : \"top\",");
            sb.Append("theme_advanced_toolbar_align : \"left\",");
            sb.Append("theme_advanced_statusbar_location : \"bottom\",");
            sb.Append("theme_advanced_resizing : true");
            sb.Append("});");
            sb.Append("</script>");
            return sb.ToString();
        }
    }
}